package com.rsscollector.model.vo;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Searchable
@Entity
@Table(name = "RSS_CONTENT")
public class RssContent implements Serializable {

    private Long id;
    private String title;
    private String newsContent;
    private String link;
    private String imageLink;
    private Date publishedDate;
    private boolean active = true;
    private String descriptionValue;
    private String descriptionType;
    private RssSource rssSource;
    private NewsGroup group;
    private boolean firstNewsOfGroup = true;
    private Date createdDate = new Date();

    // No-arg constructor
    public RssContent() {
        // empty
    }

    @SearchableId
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "RSS_CONTENT_ID")
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @SearchableProperty
    @Column(name = "TITLE", length = 500)
    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
    @Column(name = "NEWS_CONTENT", length = 10000)
    public String getNewsContent() {
        return newsContent;
    }

    public void setNewsContent(String newsContent) {
        this.newsContent = newsContent;
    }


    @Column(name = "LINK", length = 500)
    public String getLink() {
        return this.link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    @Column(name = "IMAGE_LINK", length = 500)
    public String getImageLink() {
        return imageLink;
    }

    public void setImageLink(String imageLink) {
        this.imageLink = imageLink;
    }

    @Column(name = "PUBLISHED_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getPublishedDate() {
        return this.publishedDate;
    }

    public void setPublishedDate(Date publishedDate) {
        this.publishedDate = publishedDate;
    }

    @Column(name = "ACTIVE_FLAG", nullable = true)
    public boolean isActive() {
        return this.active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    @Column(name = "FIRST_NEWS_OF_GROUP", nullable = true)
    public boolean isFirstNewsOfGroup() {
        return firstNewsOfGroup;
    }

    public void setFirstNewsOfGroup(boolean firstNewsOfGroup) {
        this.firstNewsOfGroup = firstNewsOfGroup;
    }

    @SearchableProperty
    @Column(name = "DESC_VALUE", length = 2000)
    public String getDescriptionValue() {
        return this.descriptionValue;
    }

    public void setDescriptionValue(String descriptionValue) {
        this.descriptionValue = descriptionValue;
    }

    @Column(name = "DESC_TYPE", length = 50)
    public String getDescriptionType() {
        return this.descriptionType;
    }

    public void setDescriptionType(String descriptionType) {
        this.descriptionType = descriptionType;
    }

    @ManyToOne()
    @JoinColumn(name = "RSS_SOURCE_ID")
    public RssSource getRssSource() {
        return this.rssSource;
    }

    public void setRssSource(RssSource rssSource) {
        this.rssSource = rssSource;
    }

    @ManyToOne()
    @JoinColumn(name = "NEWS_GROUP_ID")    
    public NewsGroup getGroup() {
        return this.group;
    }

    public void setGroup(NewsGroup group) {
        this.group = group;
    }
    
    @Column(name = "CREATED_DATE")
    @Temporal(TemporalType.TIMESTAMP)    
    public Date getCreatedDate() {
        return this.createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }
}
